package com.example.jdt_xiazai.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity implements BaseView {
    protected P basePresenter;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLauout());
        basePresenter=initPresenter();
        if (basePresenter!=null){
            basePresenter.bindView(this);
        }
        initView();
        initData();
    }

    protected abstract P initPresenter();


    protected abstract void initData();


    protected abstract void initView();


    protected abstract int getLauout();

    @Override
    protected void onDestroy() {
        super.onDestroy();

        basePresenter.onDestroy();
        basePresenter=null;
    }
}
